#ifndef _DISKBITTABLE_H_
#define _DISKBITTABLE_H_

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>
#include <string>
#include "bittable.h"

class BitHashTableHandle;
class DiskBitTable : public BitTable {
    public:
        DiskBitTable(std::string path);
        ~DiskBitTable();

        bool init();
        virtual bool getBitValue(unsigned long pos);
        virtual void setBitValue(unsigned long pos);
        virtual void clearBitValue(unsigned long pos);
        virtual void clear();
        void tsync(int flags = MS_SYNC);

        virtual BitHashTableHandle* getHashHandle() { return m_hashHandle; }

    private:
        std::string m_path;
        size_t m_tableSize;
        int m_tablefp;
        unsigned char* m_addr;
        BitHashTableHandle *m_hashHandle;
};

#endif
